SHELL := /bin/bash

LIBNAME=serverds18b20
SQL_LIB=`pwd`/../../sqlite3/install/lib/
SQL_PATH=`pwd`/../../sqlite3/install/include/

INS_PATH = `pwd`/../install
LIB_PATH = ${INS_PATH}/lib
INC_PATH = ${INS_PATH}/include

CC=gcc
AR=ar

all:static_lib
	@make clear
	@make install

dynamic_lib:
	${CC} -shared -fPIC *.c -o lib${LIBNAME}.so -L${SQL_LIB} -lsqlite3

static_lib:
	${CC} -c *.c -I ${INC_PATH} -I${SQL_PATH} -L${SQL_LIB} -lsqlite3
	${AR} -rcs lib${LIBNAME}.a *.o

install:
	mkdir -p ${INS_PATH}/{include,lib}
	cp -rf lib${LIBNAME}.* ${LIB_PATH}
	cp -rf *.h ${INC_PATH}

uninstall:
	rm -f ${LIB_PATH}/lib${LIBNAME}.*
	rm -f ${INC_PATH}/*.h

clear:
	rm -f *.o

clean:clear
	rm -f lib${LIBNAME}.*
